#include<iostream>
using namespace std;

void dfs(string in, string pre) {
    if(in.length() == 0)
        return;
    char root = pre[0];
    int pos = in.find(root);
    dfs(in.substr(0, pos), pre.substr(1, pos));
    dfs(in.substr(pos + 1), pre.substr(pos + 1));
    cout << root;
}

int main() {
    string in, pre;
    cin >> in >> pre;
    dfs(in, pre);
    return 0;
} 